//
//  CHTabBarController.m
//  CarFile
//
//  Created by 陈浩 on 2017/3/20.
//  Copyright © 2017年 陈浩. All rights reserved.
//

#import "CHTabBarController.h"
#import "CHHomeViewController.h"
#import "CHMineViewController.h"
#import "CHQueryViewController.h"
#import "CHSuperviseViewController.h"
#import "CHNavigationController.h"
#import "CHReviewedController.h"
@interface CHTabBarController ()

@end

@implementation CHTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.tabBar.barStyle = UIBarStyleDefault;

    self.tabBar.backgroundColor = [UIColor colorWithHexString:@"#FFFFFF"alpha:1.0f];

    self.tabBar.translucent = NO;
    
    //添加子控制器
    [self setupChildContrs];
}


-(void)setupChildContrs{
    
    CHHomeViewController *homeVC = [[CHHomeViewController alloc] init];
    [self addChildVC:homeVC title:@"首页" imgName:@"home"];
    
    
    CHSuperviseViewController *superviseVC = [[CHSuperviseViewController alloc] init];
    [self addChildVC:superviseVC title:@"监管" imgName:@"supervise"];
    
    CHReviewedController *reviewedVC = [[CHReviewedController alloc] init];
    [self addChildVC:reviewedVC title:@"审核" imgName:@"reviewed"];
    
    
    CHQueryViewController *queryVC = [[CHQueryViewController alloc] init];
    [self addChildVC:queryVC title:@"查询" imgName:@"query"];
    

    
}



-(void)addChildVC:(UIViewController *)vc title:(NSString *)title imgName:(NSString *)imgName{
    //    设置UITabbarButton 的图片和文字
    CHNavigationController *nav = [[CHNavigationController alloc] initWithRootViewController:vc];
//    vc.view.backgroundColor = [UIColor whiteColor];
    nav.tabBarItem.title = title;
    UIImage *image = [UIImage imageNamed:imgName];
    image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    nav.tabBarItem.image = image;
    
    NSString *selectedImgName = [imgName stringByAppendingString:@"_selected"];
    UIImage *selectedImg = [UIImage imageNamed:selectedImgName];
    
    //     设置图片的一个渲染的方式，返回一个没有渲染效果的图片
    selectedImg = [selectedImg imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    nav.tabBarItem.selectedImage = selectedImg;
    
    [self addChildViewController:nav];
}






- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
